<?php
use think\facade\Route;
use think\facade\Env;

Route::get('/swagger', function() {
	if(Env::get('SWAGGER.START',0)){
	   	$openapi = \OpenApi\scan('../app/api/controller');
	    header('Content-Type: application/json');
	    echo $openapi->toJson();
	}else{
		echo'{
		    "openapi": "3.0.0",
		    "info": {
		        "title": "中国翡翠API-【前台：支持在线测试】",
		        "description": "当前环境，已关闭！",
		        "termsOfService": "",
		        "contact": {
		            "email": "admin@lck.yn.cn"
		        },
		        "license": {
		            "name": "Private License",
		            "url": "URL to the license"
		        },
		        "version": "1.0.0"
		    },
		    "paths": {},
		    "components": {
		        "securitySchemes": {
		            "bearerAuth": {
		                "type": "http",
		                "name": "Authorization",
		                "in": "header",
		                "bearerFormat": "JWT",
		                "scheme": "bearer"
		            }
		        }
		    },
		    "externalDocs": {
		        "description": "http://www.lck.yn.cn",
		        "url": "http://www.lck.yn.cn"
		    }
		}';
	}
});